<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <!--    <link rel="stylesheet" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css">-->
    <!--    <script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>-->
    <link rel="stylesheet" href="__LAYUI__/css/layui.css">
    <style>
        .box {
            width: 500px;
            margin: 150px auto 0;
        }
        .box > div {
            background: #fff;
            border-radius: 4px;
            box-shadow: 5px 5px 50px #4444;
            padding: 20px;
        }
    </style>
</head>
<body style="background-image: url('/static/bg11.png')">
<div class="box">
    <div>
        <form class="layui-form">
            <div class="layui-form-item" style="color: gray;text-align: center;">
                <h2>后台管理系统</h2>
                <hr>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="name" required  lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" required  lay-verify="required" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                    <input type="text" name="verify" required  lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
                </div>
                <img src="{:captcha_src()}" class="layedit-tool-image" alt="captcha" style="cursor: pointer;width: 30%;height: 38px;border:1px solid #e6e6e6;" onclick="this.src='{:captcha_src()}?x='+Math.random();" />
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="addSubmit">登录</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script src="__LAYUI__/layui.js"></script>
<script>
    layui.use(['form','layer'], function(){
        var form  = layui.form;
        var layer = layui.layer;
        var $     = layui.jquery;
        //监听提交
        form.on('submit(addSubmit)', function(data){
            $.ajax({
                url:"{:url('login')}",
                type:'post',
                data:data.field,
                success:function(e){
                    if(e.code == 1){
                        layer.msg(e.msg,{icon:6,time:2000},function (){
                            window.location.href="{:url('admin/index')}"
                        })
                    }else{
                        layer.msg(e.msg,{icon:5,time:2000},function (){
                            window.location.reload()
                        })
                    }
                }
            });
            return false;
        });
    });
</script>
</html>